import java.util.*;

public class GreatestCommonDivisor {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.print("Ievadi skaitli: ");
        int n1 = scanner.nextInt();
        System.out.print("Un otru: ");
        int n2 = scanner.nextInt();
        
        int gcd = 1;
        int k = 2;
        while(k <= n1 && k <= n2) {
            if(n1 % k == 0 && n2 % k == 0)
                gcd = k;
            
            k++;
        }
        
        System.out.println("Lielākais dalītājs skaitļiem "
                + n1 + " un " + n2 + " ir " + gcd);
    }
}